<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>index</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="__STATIC__/xadmin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/xadmin/css/xadmin.css">
    <script src="__STATIC__/xadmin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__STATIC__/xadmin/js/xadmin.js"></script>
</head>

<body>
<div class="x-nav">
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">
                    <a class="layui-btn" onclick="backupsql()"><i class="layui-icon"></i>备份数据库</a>
                </div>
                <div class="layui-card-body ">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th width="30">标号</th>
                            <th>数据库文件</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name="list" id="vo" key="key"}
                        <tr>
                            <td>{$key}</td>
                            <td>{$vo}</td>
                            <td>
                                <!--<a href="javascript:;" class="layui-badge layui-bg-green" onclick="inputSql(this)" data-sql="{$vo}">导入数据</a>-->
                                <a href="javascript:;" class="layui-badge layui-bg-red" onclick="del(this)" data-sql="{$vo}">删除数据</a>
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    function inputSql(vs){
        var sqldata=$(vs).data('sql');
        if (!confirm("是否导入数据库文件"+sqldata)){
            return false;
        }
        $.ajax({
            url:"{:url('inputsql')}",
            data:{sqldata:sqldata},
            type:"POST",
            success:function (res){
                alert(res.msg)
            }
        })
    }
    function backupsql(){
        $.ajax({
            url:"{:url('backupSql')}",
            type:"POST",
            success:function (res){
                // alert(res.msg);
                window.location.reload();
            }
        })
    }
    function del(vd){
        var sqldata=$(vd).data('sql');
        if (!confirm("是否删除数据库文件"+sqldata)){
            return false;
        }
        $.ajax({
            url:"{:url('delsql')}",
            data:{sqldata:sqldata},
            type:"POST",
            success:function (res){
                // alert(res.msg);
                window.location.reload();
            }
        })
    }
    layui.use(['laydate', 'form'],
        function () {
            var laydate = layui.laydate;
            //执行一个laydate实例
            laydate.render({
                elem: '#start' //指定元素
            });

            //执行一个laydate实例
            laydate.render({
                elem: '#end' //指定元素
            });
        });

</script>

</html>